Release 10.1A: OpenEdge Development:
Progress 4GL Reference
REPEAT statement
Begins a block of statements that are processed repeatedly until the block ends in one of several ways.
Block properties
Iteration, record scoping, frame scoping, transactions by default.
Syntax
FORrecord[ ,record] . . .Names a record buffer and scopes the buffer to the block. The scope of a record determines when the buffer is cleared and the record is written back to the database. See OpenEdge Development: Progress 4GL Handbook for more information on record scoping and blocks.
To access a record in a table defined for multiple databases, you must qualify the record’s table name with the database name. See the Record phrase reference entry for more information.
preselect-phraseGoes through a table to select the records that meet the criteria you specify in a
record-phrase. PRESELECT creates a temporary index that contains pointers to each of the preselected records in the database table. You can then use other statements, such as FIND NEXT, to process those records. Following is the syntax forpreselect-phrase:
For more information, see the PRESELECT phrase reference entry.
query-tuning-phraseAllows programmatic control over the execution of a DataServer query. Following is the syntax for the
query-tuning-phrase:
For more information, see the OpenEdge DataServer Guides, OpenEdge Data Management: DataServer for Microsoft SQL Server , OpenEdge Data Management: DataServer for ODBC , and OpenEdge Data Management: DataServer for ORACLE .
variable=expression1TOexpression2[ BYk]Indicates the name of a field or variable whose value you are incrementing in a loop. The
expression1is the starting value forvariableon the first iteration of the loop. Thekis the amount to add tovariableafter each iteration and must be a constant. Whenvariableexceedsexpression2(or is less thanexpression2ifkis negative), the loop ends. Becauseexpression1is compared toexpression2at the start of the first iteration of the block, the block can be executed zero times. Theexpression2is reevaluated with each iteration of the block.WHILEexpressionIndicates the condition during which the REPEAT block processes the statements within it. The block iterates as long as the condition specified by the expression is TRUE. The expression is any combination of constants, field names, and variable names that yield a logical value.
TRANSACTIONIdentifies the REPEAT block as a system transaction block. Progress starts a system transaction for each iteration of a transaction block if there is no active system transaction. See OpenEdge Development: Progress 4GL Handbook for more information on transactions.
on-endkey-phraseDescribes the processing that takes place when the ENDKEY condition occurs during a block. Following is the syntax for the ON ENDKEY phrase:
For more information, see the ON ENDKEY phrase reference entry.
on-error-phraseDescribes the processing that takes place when there is an error during a block. This is the syntax for the ON ERROR phrase:
For more information, see the ON ERROR phrase reference entry.
on-quit-phraseDescribes the processing that takes place when a QUIT statement is executed during a block. This is the syntax for the ON QUIT phrase:
For more information, see the ON QUIT phrase reference entry.
on-stop-phraseDescribes the processing that takes place when the STOP conditions occurs during a block. This is the syntax for the ON STOP phrase:
For more information, see the ON STOP phrase reference entry.
frame-phraseSpecifies the overall layout and processing properties of a frame. For more information, see the Frame phrase reference entry.
ExampleIn this menu procedure, if you press END-ERROR or ENDKEY when the procedure prompts you for your menu selection, any data you have entered as a selection is undone and the procedure continues to prompt you for a menu selection:
Notes
- Within a REPEAT block, if you are using the FIND NEXT or FIND PREV statement and you change the value of an index field, Progress makes that change in the index table at the end of the UPDATE or SET statement. Therefore, if you change the value so that the record appears later in the index table, you will see the record again if you FIND NEXT. If you change the value so that the record appears earlier in the index table, you see the record again if you FIND PREV.
In this example, if you change customer 1 to customer 300, you see that customer record again at the end of the procedure.
When you use the PRESELECT option, Progress builds a special index table that is not updated when index values change. For example, add the PRESELECT option to the above example:
In this example, if you change customer 2 to customer 200, you do not see that customer record until you look it up with a new procedure.
- SpeedScript – The invalid options are:
on-endkey-phraseandon-quit-phrase.See also
DO statement, END statement, Frame phrase, ON ENDKEY phrase, ON ERROR phrase, ON QUIT phrase, ON STOP phrase
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |